import 'package:amap_base/amap_base.dart';
import 'package:flutter/material.dart';

const polylineList = const [
  LatLng(40.999401, 116.135972),
  LatLng(40.898323, 116.057694),
  LatLng(40.900430, 116.265061),
  LatLng(40.955192, 116.140092),
];

const titles = const [
  '行政区域',
  '培训机构编号',
  '驾培机构名称',
  '经营许可编号',
  '联系人',
  '联系电话',
  '经营许可日期',
  '法人代表',
  '培训机构简称',
  '营业执照注册号',
  '统一社会信息代码',
  '邮政编码',
  '经营范围',
  '经营状态',
  '创建时间',
  '更新时间',
  '培训机构地址',
];

class AreaDetail extends StatefulWidget {
  @override
  _AreaDetailState createState() => _AreaDetailState();
}

class _AreaDetailState extends State<AreaDetail> {
  AMapController _controller;
  bool unShow = true;

  @override
  void initState() {
    // TODO: implement initState
    AMap.init('aee1091befeb679a262e699b1cf0d2be');
    super.initState();
  }

  _setList() {
    List<Widget> list = List();
    for (var i = 0; i < titles.length; i++) {
      list.add(Container(
        padding: EdgeInsets.all(10),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Text(
              titles[i],
              style: TextStyle(fontSize: 14, color: Color(0xff333333)),
            ),
            Text(
              titles[i],
              style: TextStyle(fontSize: 14, color: Color(0xff333333)),
            )
          ],
        ),
      ));
    }

    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: <Widget>[
          Container(
            child: AMapView(
              onAMapViewCreated: (controller) {
                controller.addPolyline(
                  PolylineOptions(
                    latLngList: polylineList,
                    color: Colors.red,
                    isDottedLine: false,
                    isGeodesic: true,
                    dottedLineType: PolylineOptions.DOTTED_LINE_TYPE_CIRCLE,
                    width: 10,
                  ),
                );
                setState(() {
                  _controller = controller;
                });
              },
              amapOptions: AMapOptions(
                rotateGesturesEnabled: false,
                compassEnabled: true,
                zoomControlsEnabled: false,
                logoPosition: LOGO_POSITION_BOTTOM_CENTER,
                zoomGesturesEnabled: true,
                camera: CameraPosition(
                  target: LatLng(40.999401, 116.135972),
                  zoom: 10,
                ),
              ),
            ),
          ),
          Positioned(
            bottom: 0,
            child: Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                Container(
                  height: 40,
                  width: MediaQuery.of(context).size.width / 2,
                  child: FlatButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text(
                      '审核',
                      style: TextStyle(fontSize: 16, color: Colors.black),
                    ),
                  ),
                ),
                Container(
                  height: 40,
                  width: MediaQuery.of(context).size.width / 2,
                  child: FlatButton(
                    color: Color(0xff23AFDC),
                    onPressed: () {},
                    child: Text(
                      '解除备案',
                      style: TextStyle(fontSize: 16, color: Colors.white),
                    ),
                  ),
                ),
              ],
            ),
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Container(
                margin: EdgeInsets.fromLTRB(30, 30, 30, 0),
                color: Colors.white,
                height: 40,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    IconButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      icon: Icon(Icons.arrow_back_ios),
                      iconSize: 24,
                      color: Colors.black,
                    ),
                    GestureDetector(
                        onTap: () {
                          setState(() {
                            unShow = !unShow;
                          });
                        },
                        child: Text(
                          '教学区域基本信息',
                          style:
                              TextStyle(color: Color(0xff333333), fontSize: 14),
                        ))
                  ],
                ),
              ),
              Offstage(
                offstage: unShow,
                child: ListView(
                  children: _setList(),
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
